package com.kinggm.service.observer.impl;

import com.kinggm.service.observer.DisplayElement;
import com.kinggm.service.observer.Observer;
import com.kinggm.service.observer.Subject;

public class CurrentConditionsDisplay  implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private Subject subject;

    public CurrentConditionsDisplay(Subject subject) {
        this.subject = subject;
        subject.registerObserver(this);
    }

    public void update(float temperature, float humidity, float pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        display();
    }

    public void display() {
        System.out.println("CurrentConditionsDisplay  \n 温度: " + temperature + "℃" + "湿度：" + humidity + "%");
    }

}
